package cn.iocoder.yudao.module.iot.dal.mysql.scene;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.iot.dal.dataobject.scene.IotSceneActionDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 场景动作 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface IotSceneActionMapper extends BaseMapperX<IotSceneActionDO> {

    default List<IotSceneActionDO> selectListBySceneId(Long sceneId) {
        return selectList(new LambdaQueryWrapperX<IotSceneActionDO>()
                .eq(IotSceneActionDO::getSceneId, sceneId)
                .orderByAsc(IotSceneActionDO::getOrderNum));
    }

    default void deleteBySceneId(Long sceneId) {
        delete(new LambdaQueryWrapperX<IotSceneActionDO>()
                .eq(IotSceneActionDO::getSceneId, sceneId));
    }

    default List<IotSceneActionDO> selectListByDeviceId(Long deviceId) {
        return selectList(new LambdaQueryWrapperX<IotSceneActionDO>()
                .eq(IotSceneActionDO::getDeviceId, deviceId)
                .orderByAsc(IotSceneActionDO::getOrderNum));
    }

    default List<IotSceneActionDO> selectListByProductId(Long productId) {
        return selectList(new LambdaQueryWrapperX<IotSceneActionDO>()
                .eq(IotSceneActionDO::getProductId, productId)
                .orderByAsc(IotSceneActionDO::getOrderNum));
    }

}